package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.base.SceneType;
import com.enation.app.javashop.model.base.vo.EmailVO;
import com.enation.app.javashop.service.base.service.EmailManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author fk
 * @version v2.0
 * @Description:
 * @date 2018/8/15 9:46
 * @since v7.0.0
 */
@RestController
@RequestMapping("/client/email")
@ApiIgnore
public class EmailClientController {

    @Autowired
    private EmailManager emailManager;

    @PostMapping
    public void sendEmail(@RequestBody EmailVO emailVO) {
        emailManager.sendEmail(emailVO);
    }

    @RequestMapping(value = "/valid", method = RequestMethod.POST)
    public boolean valid(@RequestParam("scene") String scene, @RequestParam("email")String email, @RequestParam("code")String code){

        return emailManager.valid(scene, email, code);
    }

    @RequestMapping(value = "/send", method = RequestMethod.POST)
    public void sendEmailMessage(@RequestParam("by_name")String byName, @RequestParam("email")String email, @RequestParam("scene_type") SceneType sceneType) {
        emailManager.sendEmailMessage(byName, email, sceneType);
    }

}
